home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.image;
-
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import java.awt.image.ColorModel;
- import java.awt.image.ImageConsumer;
- import java.awt.image.ImageObserver;
- import java.util.Hashtable;
-
- public class ImageRepresentation extends ImageWatched implements ImageConsumer {
- int pData;
- InputStreamImageSource src;
- Image image;
- int tag;
- int srcW;
- int srcH;
- int width;
- int height;
- int hints;
- int availinfo;
- boolean offscreen;
- Rectangle newbits;
- private boolean consuming = false;
- private int numWaiters;
-
- ImageRepresentation(Image var1, int var2, int var3, int var4) {
- this.image = var1;
- this.tag = var4;
- if (var2 != 0 && var3 != 0) {
- if (var2 > 0) {
- this.width = var2;
- this.availinfo |= 1;
- }
-
- if (var3 > 0) {
- this.height = var3;
- this.availinfo |= 2;
- }
-
- if (this.image.getSource() instanceof InputStreamImageSource) {
- this.src = (InputStreamImageSource)this.image.getSource();
- }
-
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- native void offscreenInit(Color var1);
-
- public synchronized void reconstruct(int var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- int var2 = var1 & ~this.availinfo;
- if (var2 != 0) {
- ++this.numWaiters;
-
- try {
- this.startProduction();
-
- for(int var9 = var1 & ~this.availinfo; var9 != 0; var9 = var1 & ~this.availinfo) {
- try {
- this.wait();
- } catch (InterruptedException var7) {
- Thread.currentThread().interrupt();
- return;
- }
- }
-
- } finally {
- this.decrementWaiters();
- }
- }
- }
-
- public synchronized void setDimensions(int var1, int var2) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- this.srcW = var1;
- this.srcH = var2;
- if ((this.availinfo & 1) == 0 && (this.availinfo & 2) == 0) {
- this.width = var1;
- this.height = var2;
- } else if ((this.availinfo & 1) == 0) {
- this.width = var1 * this.height / var2;
- } else {
- if ((this.availinfo & 2) != 0) {
- return;
- }
-
- this.height = var2 * this.width / var1;
- }
-
- if (this.srcW > 0 && this.srcH > 0 && this.width > 0 && this.height > 0) {
- this.availinfo |= 3;
- } else {
- this.imageComplete(1);
- }
- }
-
- public void setProperties(Hashtable var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- }
-
- public void setColorModel(ColorModel var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- }
-
- public void setHints(int var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- this.hints = var1;
- }
-
- private native boolean setBytePixels(int var1, int var2, int var3, int var4, ColorModel var5, byte[] var6, int var7, int var8);
-
- public void setPixels(int var1, int var2, int var3, int var4, ColorModel var5, byte[] var6, int var7, int var8) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- boolean var9 = false;
- synchronized(this){}
-
- int var10;
- int var11;
- int var12;
- int var13;
- try {
- if (this.newbits == null) {
- this.newbits = new Rectangle(0, 0, this.width, this.height);
- }
-
- if (this.setBytePixels(var1, var2, var3, var4, var5, var6, var7, var8)) {
- this.availinfo |= 8;
- var9 = true;
- }
-
- var10 = this.newbits.x;
- var11 = this.newbits.y;
- var12 = this.newbits.width;
- var13 = this.newbits.height;
- } catch (Throwable var16) {
- throw var16;
- }
-
- if (var9 && !this.offscreen) {
- ((ImageWatched)this).newInfo(this.image, 8, var10, var11, var12, var13);
- }
-
- }
-
- private native boolean setIntPixels(int var1, int var2, int var3, int var4, ColorModel var5, int[] var6, int var7, int var8);
-
- public void setPixels(int var1, int var2, int var3, int var4, ColorModel var5, int[] var6, int var7, int var8) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- boolean var9 = false;
- synchronized(this){}
-
- int var10;
- int var11;
- int var12;
- int var13;
- try {
- if (this.newbits == null) {
- this.newbits = new Rectangle(0, 0, this.width, this.height);
- }
-
- if (this.setIntPixels(var1, var2, var3, var4, var5, var6, var7, var8)) {
- this.availinfo |= 8;
- var9 = true;
- }
-
- var10 = this.newbits.x;
- var11 = this.newbits.y;
- var12 = this.newbits.width;
- var13 = this.newbits.height;
- } catch (Throwable var16) {
- throw var16;
- }
-
- if (var9 && !this.offscreen) {
- ((ImageWatched)this).newInfo(this.image, 8, var10, var11, var12, var13);
- }
-
- }
-
- private native boolean finish(boolean var1);
-
- public void imageComplete(int var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- boolean var2;
- short var3;
- switch (var1) {
- case 1:
- this.image.addInfo(64);
- var2 = true;
- var3 = 64;
- this.dispose();
- break;
- case 2:
- var2 = false;
- var3 = 16;
- break;
- case 3:
- var2 = true;
- var3 = 32;
- if (this.finish(false)) {
- this.image.getSource().requestTopDownLeftRightResend(this);
- this.finish(true);
- }
- break;
- case 4:
- default:
- var2 = true;
- var3 = 128;
- }
-
- synchronized(this){}
-
- try {
- if (var2) {
- this.image.getSource().removeConsumer(this);
- this.consuming = false;
- this.newbits = null;
- }
-
- this.availinfo |= var3;
- this.notifyAll();
- } catch (Throwable var6) {
- throw var6;
- }
-
- if (!this.offscreen) {
- ((ImageWatched)this).newInfo(this.image, var3, 0, 0, this.width, this.height);
- }
-
- }
-
- void startProduction() {
- if (!this.consuming) {
- this.consuming = true;
- this.image.getSource().startProduction(this);
- }
-
- }
-
- private synchronized void checkConsumption() {
- if (super.watchers == null && this.numWaiters == 0 && (this.availinfo & 32) == 0) {
- this.dispose();
- }
-
- }
-
- public synchronized void removeWatcher(ImageObserver var1) {
- super.removeWatcher(var1);
- this.checkConsumption();
- }
-
- private synchronized void decrementWaiters() {
- --this.numWaiters;
- this.checkConsumption();
- }
-
- public boolean prepare(ImageObserver var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 64) != 0) {
- if (var1 != null) {
- var1.imageUpdate(this.image, 192, -1, -1, -1, -1);
- }
-
- return false;
- } else {
- boolean var2 = (this.availinfo & 32) != 0;
- if (!var2) {
- ((ImageWatched)this).addWatcher(var1);
- this.startProduction();
- }
-
- return var2;
- }
- }
-
- public int check(ImageObserver var1) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 96) != 0) {
- ((ImageWatched)this).addWatcher(var1);
- }
-
- return this.availinfo;
- }
-
- synchronized native void imageDraw(Graphics var1, int var2, int var3, Color var4);
-
- public boolean drawImage(Graphics var1, int var2, int var3, Color var4, ImageObserver var5) {
- if (this.src != null) {
- this.src.checkSecurity((Object)null, false);
- }
-
- if ((this.availinfo & 64) != 0) {
- if (var5 != null) {
- var5.imageUpdate(this.image, 192, -1, -1, -1, -1);
- }
-
- return false;
- } else {
- boolean var6 = (this.availinfo & 32) != 0;
- if (!var6) {
- ((ImageWatched)this).addWatcher(var5);
- this.startProduction();
- }
-
- this.imageDraw(var1, var2, var3, var4);
- return var6;
- }
- }
-
- private native void disposeImage();
-
- synchronized void abort() {
- this.image.getSource().removeConsumer(this);
- this.consuming = false;
- this.newbits = null;
- this.disposeImage();
- ((ImageWatched)this).newInfo(this.image, 128, -1, -1, -1, -1);
- this.availinfo &= -121;
- }
-
- synchronized void dispose() {
- this.image.getSource().removeConsumer(this);
- this.consuming = false;
- this.newbits = null;
- this.disposeImage();
- this.availinfo &= -57;
- }
-
- public void finalize() {
- this.disposeImage();
- }
- }
-